#ifndef AT25DEVICE_H
#define	AT25DEVICE_H

#include "spidevice.h"

#ifdef	__cplusplus
extern "C" {
#endif	
	
#ifdef   _AT25_MODULE_
#define  AT25_EXT
#else
#define  AT25_EXT  extern
#endif

#define AT25C1024                       1

#if AT25C1024 > 0
#define AT25_CHIP_SIZE                  0x20000
#define AT25_CHIP_MASK                  0x1FFFF
#define AT25_SECTOR_SIZE                0x8000
#define AT25_SECTOR_MASK                0x7FFF
#define AT25_PAGE_SIZE                  0x100
#define AT25_PAGE_MASK                  0xFF
#endif

#define AT25_STATUS_WIP_MASK            0x01
#define AT25_STATUS_WEL_MASK            0x02
#define AT25_STATUS_BP_MASK             0x0C
#define AT25_STATUS_WPEN_MASK           0x80


#define AT25CMD_READ                    0x03
#define AT25CMD_WRITE                   0x02
#define AT25CMD_WREN                    0x06
#define AT25CMD_WTDI                    0x04
#define AT25CMD_RDSR                    0x05
#define AT25CMD_WRSR                    0x01
#define AT25CMD_PAGE_ERASE              0x42
#define AT25CMD_SECTOR_ERASE            0xD8
#define AT25CMD_CHIP_ERASE              0xC7
#define AT25CMD_RDID                    0xAB
#define AT25CMD_DPD                     0xB9  


	uint8_t AT25_Read(uint8_t *Des, uint32_t Sda, uint16_t Len);
	uint8_t AT25_Write(uint8_t *Src, uint32_t Sda, uint16_t Len);
	uint8_t AT25_WriteEnable(void);
	uint8_t AT25_WriteDisable(void);
	uint8_t AT25_GetStatus(void);
	uint8_t AT25_SetStatus(uint8_t Status);
	uint8_t AT25_PageErase(uint32_t Sda);
	uint8_t AT25_SectorErase(uint32_t Sda);
	uint8_t AT25_ChipErase(void);
	

#undef AT25_EXT

#ifdef	__cplusplus
}
#endif

#endif	/* AT25DEVICE_H */
